package xinyu.customer.news.data;

import com.logos.common.source.network.entity.BaseNetEntity;

import xinyu.customer.bean.NewsMainNetTopBean;
import xinyu.customer.bean.NewsMainTopBean;
import xinyu.customer.bean.UserEntity;
import xinyu.customer.login.data.LoginContract;
import xinyu.customer.login.data.LoginDataSource;

public class NewsTabMainPresenter implements NewsTabMainContract.Presenter {

    private NewsTabMainContract.View mView;
    private NewsTabMainDataSource mDataSource;

    public NewsTabMainPresenter(NewsTabMainContract.View view, NewsTabMainDataSource dataSource) {

        if (view == null || dataSource == null) {
            throw new IllegalArgumentException("view and dataSource must not be empty");
        }

        mView = view;
        mDataSource = dataSource;
        view.setPresenter(this);
    }


    @Override
    public void create() {

    }

    @Override
    public void destroy() {

    }

    @Override
    public void getNewsTopMain(String custId) {
        mView.showLoading();
        mDataSource.getNewsTabMainData(custId, new NewsTabMainDataSource.NewsTabMainCallback() {
            @Override
            public void onNewsTabMainComplete(BaseNetEntity<NewsMainNetTopBean> result) {
                mView.hideLoading();
                mView.onNewsTabMainTopSuccess(result);
            }

            @Override
            public void onFailed(int errorId, String errorMessage) {
                mView.hideLoading();
                mView.showMessage(errorMessage);
            }
        });
    }
}
